package com.kylin.common.entity;

import java.util.Hashtable;

import com.kylin.common.exception.BusinessException;
import com.kylin.common.util.UUID;
import com.kylin.hibernate.CriteriaInfo;
import com.kylin.hibernate.QueryInfo;


public class UserCache {
    private Hashtable cache = new Hashtable();
    
    /**
     * 存放查询条件信息
     * @param queryInfo
     * @return
     */
    public String addQueryInfo(QueryInfo queryInfo){
    	String QueryKey = UUID.create("query");
    	cache.put(QueryKey, queryInfo);
    	return QueryKey;
    }
        
    /**
     * 取得查询条件信息
     * @param key
     * @return
     */
    public QueryInfo getQueryInfo(String key){
    	Object obj = cache.get(key);
    	return (QueryInfo)obj;
    }
    
    /**
     * 存放查询器对象
     * @param criteriaInfo
     * @return
     */
    public String addCriteriaInfo(CriteriaInfo criteriaInfo){
    	//String QueryKey = UUID.create("query");
    	cache.put( ""+criteriaInfo.hashCode(), criteriaInfo);
    	return ""+criteriaInfo.hashCode();
    }
        
    /**
     * 取得查询器对象
     * @param key
     * @return
     */
    public CriteriaInfo getCriteriaInfo(Object key){
    	Object obj = cache.get(key);
    	return (CriteriaInfo)obj;
    }
    
    /**
     * 存放用户自定义对象
     * @param key
     * @param obj
     */
    public void addObject(String key,Object obj){
    	cache.put(key, obj);
    }
    
    public Object getObject(String key){
    	return cache.get(key);
    }
    
    public static void main(String[]s) throws BusinessException {
    	UserCache uc = new UserCache();
    	//System.out.print(uc.getQueryString(" key"));
    	
    }
}
